package com.woniu.user.service.impl;

import com.woniu.user.exception.WebException;
import com.woniu.user.exception.WebExceptionCode;
import com.woniu.user.model.Occupy;
import com.woniu.user.dao.OccupyDao;
import com.woniu.user.service.OccupyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 教练时间占用表 服务实现类
 * </p>
 *
 * @author Silas
 * @since 2023-02-15
 */
@Service
@Slf4j
public class OccupyServiceImpl extends ServiceImpl<OccupyDao, Occupy> implements OccupyService {

    @Resource
    private OccupyDao occupyDao;


    @Override
    public void createOccupy() {

    }

    // 取消占用状态
    @Override
    public void cancelOccupy(Integer occpuyId) {
        log.info("取消课程占用状态{}", occpuyId);
        Occupy occupy = this.getById(occpuyId);
        if (occupy == null) throw new WebException(WebExceptionCode.OCCUPY_IS_NOT_EXISTS);
        occupy.setState("无效");
        this.updateById(occupy);
    }


}
